package com.example.beson.androiddemo.utils;

import android.app.Dialog;
import android.content.Context;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.example.beson.androiddemo.R;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.drawee.view.SimpleDraweeView;

/**
 * Created by 史国院 on 2017/5/26.
 * Desc ******
 */

public class DialogUtils {
    private Context mContext;

    public DialogUtils(Context mContext) {
        this.mContext = mContext;
    }
    public static Dialog CreateDialog(Context context){
        if(context!=null){
            View view= LayoutInflater.from(context).inflate(R.layout.dialog_layout,null);
            LinearLayout dialog_layout= (LinearLayout) view.findViewById(R.id.dialog_layout);
            SimpleDraweeView dialog_draweeview= (SimpleDraweeView) view.findViewById(R.id.dialog_draweeview);
            String url="res://com.example.beson.androiddemo/"+R.mipmap.image3;
            DraweeController draweeController= Fresco.newDraweeControllerBuilder().setUri(Uri.parse(url)).setAutoPlayAnimations(true).build();
            dialog_draweeview.setController(draweeController);

            Dialog dialog=new Dialog(context,R.style.Loooading_dialog);

            dialog.setContentView(dialog_layout,new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
            return dialog;
        }else{
            return null;
        }
    }
}
